#include "GribReader.h"
#include "GribWrapper.h"
#include "GribCompute.h"

namespace OCPP
{
	using namespace Volume;
	GribReader::GribReader()
	{
		ncWrapper = std::make_unique<GribWrapper>();
	}

	GribReader::~GribReader()
	{

	}

	Json::Value GribReader::getVars()
	{
		return ncWrapper->getVars();
	}

	bool GribReader::open(String fileName, bool printDescription)
	{
		mFileName = fileName;
		bool isOpen = ncWrapper->open(fileName);
		if (isOpen && printDescription) {
			ncWrapper->print();
		}

		return isOpen;
	}

	void GribReader::extract(String varName, const VolumeOptions& options, int levelIndex, int timeIndex)
	{
		ncWrapper->extract(varName, levelIndex, timeIndex, options);
	}

	void GribReader::extract(VolumeComputeList computeList
		, std::shared_ptr<VolumeAlgorithm> ncAlgorithm
		, const VolumeOptions& options
		, int levelIndex
		, int timeIndex)
	{
		GribCompute compute;
		compute.setComputeList(computeList);
		compute.setAlgorithm(ncAlgorithm);
		compute.extract(levelIndex, timeIndex, options);
	}
}